package com.cloud.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class JsonUtil {

    private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);

    private JsonUtil(){}

    /**
     *
     * @param object
     * @return
     */
    public static String parseObjectToJson(Object object){
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException e) {
            logger.info("Parse MktAdPositionModel  to json has error." , e);
        }
        return null;
    }

    /**
     *
     * @param args
     */
    public static void main(String[] args) {
        logger.info(parseObjectToJson(null));
    }

}
